package com.thkj.dao;

import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;


public interface DevicesMapper extends Mapper<T> {



    /**
     *  根据经营ID 和时间(天) 查询设备一天的消毒情况
     *
     * @param individual_id
     * @return timeStr   时间字段,
     */
    @Select("SELECT id,name,#{timeStr} as timeStr " +
            "FROM thkj_devices  " +
            "where individual_id = #{individual_id} " +
            "and device_type = 1 ")
    @Results(value = {
            @Result(column = "id", property = "id", javaType = String.class),
            @Result(column = "name", property = "name", javaType = String.class),
            @Result(column = "device_id=id,timeStr= timeStr", property = "duration", one = @One(select = "com.thkj.dao.DisinfectRecordMapper.queryYearSumByWorkerId"), javaType = Double.class),
    })
    List<Map> queryDisinfectYearByIndividualId(@Param("individual_id") String individual_id, @Param("timeStr") String timeStr);




    /**
     *  根据经营ID 和时间(月) 查询设备一天的消毒情况
     *
     * @param individual_id
     * @return timeStr   时间字段,
     */
    @Select("SELECT id,name,#{timeStr} as timeStr " +
            "FROM thkj_devices  " +
            "where individual_id = #{individual_id} " +
            "and device_type = 1 ")
    @Results(value = {
            @Result(column = "id", property = "id", javaType = String.class),
            @Result(column = "name", property = "name", javaType = String.class),
            @Result(column = "device_id=id,timeStr= timeStr", property = "duration", one = @One(select = "com.thkj.dao.DisinfectRecordMapper.queryMonthSumByWorkerId"), javaType = Double.class),
    })
    List<Map> queryDisinfectMonthByIndividualId(@Param("individual_id") String individual_id, @Param("timeStr") String timeStr);





    /**
     *  根据经营ID 和 本周 查询设备一天的消毒情况
     *
     * @param individual_id
     * @return timeStr   时间字段,
     */
    @Select("SELECT id,name,#{timeStr} as timeStr " +
            "FROM thkj_devices  " +
            "where individual_id = #{individual_id} " +
            "and device_type = 1 ")
    @Results(value = {
            @Result(column = "id", property = "id", javaType = String.class),
            @Result(column = "name", property = "name", javaType = String.class),
            @Result(column = "device_id=id,timeStr= timeStr", property = "duration", one = @One(select = "com.thkj.dao.DisinfectRecordMapper.queryWeekSumByWorkerId"), javaType = Double.class),
    })
    List<Map> queryDisinfectWeekByIndividualId(@Param("individual_id") String individual_id, @Param("timeStr") String timeStr);



    /**
     *  根据经营ID 和时间(天) 查询设备一天的消毒情况
     *
     * @param individual_id
     * @return timeStr   时间字段,
     */
    @Select("SELECT id,name,#{timeStr} as timeStr " +
            "FROM thkj_devices  " +
            "where individual_id = #{individual_id} " +
            "and device_type = 1 ")
    @Results(value = {
            @Result(column = "id", property = "id", javaType = String.class),
            @Result(column = "name", property = "name", javaType = String.class),
            @Result(column = "device_id=id,timeStr= timeStr", property = "duration", one = @One(select = "com.thkj.dao.DisinfectRecordMapper.queryDaySumByWorkerId"), javaType = Double.class),
    })
    List<Map> queryDisinfectDayByIndividualId(@Param("individual_id") String individual_id, @Param("timeStr") String timeStr);

}

